import { api } from "@/utils/api.js";
import { showToast } from "vant";

export function formatMusicTime(interval) {
    interval = interval | 0
    const minute = interval / 60 | 0
    const second = interval % 60
    return `${minute}:${second}`
}

export async function collection (item) {
        const res = await api('/api/index/collection_classify_like','post',{id:item.id})
        //console.log(res);
        if(Array.isArray(res)) {
            item.has_like = 1;
            item.like_count ++;
            showToast('点赞成功');
        }
    }

export async function uncollection (item) {
        const res = await api('/api/index/collection_classify_cancle_like','post',{id:item.id})
        //console.log(res);
        if(Array.isArray(res)) {
            item.has_like = 0
            item.like_count --;
            showToast('取消点赞成功');
        }
}






